package com.starleague.game.android;

import java.util.List;

//import com.starleague.entity.android.EntityArrayAdapter;
import com.starleague.game.HasPlayers;
import com.starleague.game.IPlayer;

import android.app.Fragment;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

public class PlayerListFragment
        extends Fragment
        implements AdapterView.OnItemClickListener
{
    @Override
    public View onCreateView(final LayoutInflater inflater,
                             ViewGroup container,
                             Bundle savedInstanceState)
    {
        View playerListLayout = inflater.inflate(R.layout.player_list, container, false);
        // Context context = playerListLayout.getContext();
        //
        // ListView playerListView = (ListView)
        // playerListLayout.findViewById(R.id.player_list_view);
        //
        // @SuppressWarnings("unchecked")
        // List<AndroidPlayer> playerList = (List<AndroidPlayer>) ((HasPlayers)
        // context).getPlayers();
        //
        // EntityArrayAdapter<AndroidPlayer> playerListAdapter = new
        // EntityArrayAdapter<>(inflater,
        // R.layout.player_list_item,
        // playerList);
        //
        // playerListView.setAdapter(playerListAdapter);
        // playerListView.setOnItemClickListener(this);

        return playerListLayout;
    }

    private int backColor = Color.GREEN;

    @Override
    public void onItemClick(AdapterView<?> parent,
                            View view,
                            int position,
                            long id)
    {
        // AndroidCounterPlayer player =
        // this.playerListAdapter.getItem(position);
        // this.adapter.remove(player);
        // view.setAlpha((view.getAlpha() + 0.2f) % 1.0f);
        this.backColor = this.backColor * 13;
        view.setBackgroundColor(this.backColor);
    }
}
